package org.millioncall.yueyoga.admin.dao.impl;

import java.util.List;
import java.util.Map;

import org.millioncall.openplatform.common.PaginateParams;
import org.millioncall.openplatform.common.PaginatedList;
import org.millioncall.openplatform.common.StartLimitPairImpl;
import org.millioncall.openplatform.dao.PreparedQuery;
import org.millioncall.yueyoga.admin.dao.BaseDao;
import org.millioncall.yueyoga.admin.dao.GoodTypeDAO;
import org.millioncall.yueyoga.admin.model.GoodType;
import org.springframework.stereotype.Repository;

/**
 * @author lisj Mar 27, 2014 2:26:15 PM
 */
@Repository
public class GoodTypeDAOImpl extends BaseDao implements GoodTypeDAO {


	@Override
	public int deleteById(Integer id) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int deleteByIds(String[] strIds) {
		int count=0;
		for(String id:strIds){
			count=count+this.getPagableSqlSessionTemplate().update("updateGoodTypeEnable", Integer.parseInt(id));
		}
		return count;
	}
	@Override
	public GoodType findGoodTypeById(Integer id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public PaginatedList<GoodType> findGoodTypeInPage(Map<String, Object> map,
			int start, int limit) {
		PreparedQuery<GoodType> pq = this.getPagableSqlSessionTemplate().findAll("findGoodTypeInPage", map);
		PaginatedList<GoodType> pl = pq.list(new PaginateParams(
				new StartLimitPairImpl(start, limit)));
		return pl.size() > 0 ? pl : null;
	}

	@Override
	public List<GoodType> findAll() {
		// TODO Auto-generated method stub
		return this.getPagableSqlSessionTemplate().selectList("findGoodTypeAll");
	}

	@Override
	public int save(GoodType goodType) {
		// TODO Auto-generated method stub
		return this.getPagableSqlSessionTemplate().insert("saveGoodType", goodType);
	}

	@Override
	public int update(GoodType goodType) {
		// TODO Auto-generated method stub
		return 0;
	}

}
